import time

from selenium.webdriver.common.by import By

from common.base import Base
from common.functions import host, browser_operation


class IndexPage(Base):
    # 主页路径
    index_url = host

    def font_text(self):
        # 获取登陆后用户名
        return self.get_element_text((By.CLASS_NAME, 'f4_b'))

    def logout(self):
        # 登陆后退出
        self.click((By.LINK_TEXT, '退出'))

    def reg_btn(self):
        # 定位到注册按钮点击
        self.click((By.LINK_TEXT, '免费注册'))

    def a_logout(self):
        self.click((By.LINK_TEXT, '退出'))
        time.sleep(2)

    def search(self):
        return self.get_element_text((By.CLASS_NAME, 'f4_b'))

    def loginout(self):
        self.click((By.LINK_TEXT, '退出'))
        time.sleep(1)



if __name__ == '__main__':
    driver = browser_operation()
    index = IndexPage(driver)
    index.get(host)
